home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Newton Platform Info / Newton 2.0 Sample Code / Desktop Connectivity / SoupDrink-2 / SoupDrink-Mac-2 / AppDialogs.c next >
Encoding:
C/C++ Source or Header  |  1996-02-09  |  3.0 KB  |  137 lines  |  [TEXT/R*ch]

  1. /*
  2. **        File:        AppDialogs.c
  3. **
  4. **        Contains:   Input and status dialogs for Macintosh SoupDrink application
  5. **
  6. **        Written by:    Rob Langhorne, mods by David Fedor
  7. **
  8. **      Copyright © 1995-1996 by Apple Computer, Inc.  All rights reserved.
  9. **
  10. **      You may incorporate this sample code into your applications without
  11. **      restriction.  This sample code has been provided "AS IS" and the
  12. **      responsibility for its operation is 100% yours.  You are not
  13. **      permitted to modify and redistribute the source as "DTS Sample Code."
  14. **      If you are going to re-distribute the source, we require that you
  15. **      make it clear in the source that the code was descended from
  16. **      Apple-provided sample code, but that you've made changes.
  17. */
  18.  
  19. #include <Dialogs.h>
  20. #include <String.h>
  21. #include <Strings.h>
  22. #include "AppDialogs.h"
  23.  
  24. // ok_outline
  25. //
  26. // outlines the "OK" button with a heavy border
  27. ok_outline(DialogPtr theDialog,short item)
  28. {
  29.     CGrafPtr    oldPort;
  30.     short        itemType;
  31.     Rect        itemRect;
  32.     Handle        itemHdl;
  33.     
  34.     GetDItem(theDialog,item,&itemType,&itemHdl,&itemRect);
  35.     if((**(ControlHandle)itemHdl).contrlHilite == 0xff)        /* cntrl is inactive */
  36.         return 0;
  37.  
  38.     GetPort( (GrafPtr *)&oldPort);
  39.     SetPort(theDialog);
  40.     PenSize(3,3);
  41.     InsetRect(&itemRect,-4,-4);
  42.     FrameRoundRect(&itemRect,16,16);
  43.     PenSize(1,1);
  44.     SetPort( (GrafPtr)oldPort);
  45.     return 0;
  46. }
  47.  
  48. Boolean inputDialog(char *inputText, char* initString, char* label)
  49. {
  50.       DialogRecord     Dialog;
  51.       short            Item;
  52.     short            itemType;
  53.     Rect            itemRect;
  54.     Handle            txHdl;
  55.     Str255            tempStr ;
  56.     Str255            initStr ;
  57.     
  58.       GetNewDialog (kInputDialog, &Dialog, (WindowPtr)-1); /***** errors? */
  59.  
  60.  
  61.     GetDItem((DialogPtr)&Dialog, LABEL, &itemType, &txHdl, &itemRect);
  62.     strcpy((char*) initStr, label);
  63.     c2pstr((char*) initStr);
  64.     SetIText(txHdl,initStr);
  65.  
  66.     GetDItem((DialogPtr)&Dialog, INPUT_TEXT, &itemType, &txHdl, &itemRect);
  67.     strcpy((char*) initStr, initString);
  68.     c2pstr((char*) initStr);
  69.     SetIText(txHdl,initStr);
  70.  
  71.     ok_outline ((DialogPtr)&Dialog, OK) ;
  72.       do 
  73.       {
  74.         ModalDialog (NULL, &Item);
  75.      } while ((Item != OK) && (Item != CANCEL)) ;
  76.     
  77.     if (Item == OK)
  78.     {
  79.         GetIText(txHdl,tempStr);
  80.         p2cstr(tempStr);
  81.     
  82.         strcpy(inputText, (char *)tempStr);
  83.     }
  84.     else
  85.         inputText = nil;
  86.         
  87.     CloseDialog ((DialogPtr)&Dialog);
  88.     
  89.     return true;
  90.  
  91. }
  92.  
  93.  
  94. void PostAlertMessage(char*a, char*b, char*c, char*d)
  95. {
  96.     Str255 aa, bb, cc, dd;
  97.     strcpy(( char*) aa, a); strcpy(( char*) bb, b); 
  98.     strcpy(( char*) cc, c); strcpy(( char*) dd, d);
  99.     ParamText(c2pstr((char*)aa), c2pstr((char*)bb), c2pstr((char*)cc), c2pstr((char*)dd));
  100.     Alert(kInfoDialog, nil);
  101. }
  102.  
  103.  
  104. /*
  105.  * ShowSplash
  106.  *
  107.  * Show our splash screen
  108.  */
  109. void ShowSplash(DialogPtr *splash) 
  110. {
  111.     long        pause;            //    For use in delay
  112.     Handle        Hdl=nil;        
  113.  
  114.     *splash = GetNewDialog(kSplashDialog, nil, (WindowPtr)-1) ;
  115.     if (*splash) {
  116.         SetPort(*splash);
  117.         ShowWindow(*splash);
  118.         DrawDialog(*splash);
  119.  
  120.         Delay(60L,&pause);
  121.     }
  122. }
  123.  
  124. /*
  125.  * HideSplash
  126.  *
  127.  * Hide our splash screen
  128.  */
  129. void HideSplash(DialogPtr splash) 
  130. {
  131.     if (splash) {
  132.         HideWindow(splash);
  133.         DisposeDialog(splash);
  134.     }
  135. }
  136.  
  137.